package com.ykq.system.controller;

import com.ykq.system.entity.User;
import com.ykq.system.vo.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author 闫克起  aaa
 * @since 2022-08-08
 */
@RestController
@RequestMapping("/system/user")
public class UserController {
    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("getInfo")
    public CommonResult getInfo(HttpServletRequest request){
        String token = request.getHeader("token");
        System.out.println(token);
        //根据token从redis中获取用户信息
        ValueOperations forValue = redisTemplate.opsForValue();
        User o = (User) forValue.get(token);
        return new CommonResult(2000,"获取用户信息成功",o);
    }

}
